package com.example.demo.controller;

import com.example.demo.pojo.User;
import com.example.demo.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class PageController {

    @Autowired
    private IUserService IUserService;


    @GetMapping("/userTest")
    @ResponseBody
    public User findByUid(Integer uid) {
        return IUserService.findByUid(uid);
    }

    @GetMapping("/{page}")
    public String login(@PathVariable("page") String page) {
        return page;
    }

    @GetMapping("/leave")
    public String leave(HttpServletRequest request) {
        request.getSession().invalidate();
        return "redirect:/";
    }

//    @GetMapping("/register")
//    public String register() {
//        return "register";
//    }
//
//    @GetMapping("/shopCart")
//    public String showShopCart() {
//        return "shopCart"
//    }

}
